/**
 * create by young (young2f@outlook.com) on 2020/12/3
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmc');
  const json = {
    tenantCode: { type: String, required: true, desc: '租户代码' },
    tenantName: { type: 'string' },
    treeId: { type: 'string' },
    createUser: { type: 'string' },
    createUsername: { type: 'string' },
    isEnabled: { type: 'boolean' },
    isAdmin: { type: Boolean },
    roleName: { type: 'string' },
    roleCode: { type: 'string' },

    isTenantSuperUser:{type:"boolean"},//是否是租户超级管理员，可以管理租户下的菜单权限
    memo: { type: 'string' },
    menus: { type: Array },
    capability: { type: Array },
  }
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('Role', _schema);
};
